const express=require('express');
const path=require('path');
const fs=require('fs')
const url=require('url') //解析 参数实现对象的形式

const router=express.Router()


//这个是路由1
router.get('/',(req,res)=>{
    // fs.readFile(path.resolve(__dirname,'./public/home.html'),(err,data)=>{
    //     if(err)throw new Error(err)
    //     res.send(data)
    // })
    
    
    res.send({name:'home',...req.aaa})
})

//路由二

router.get('/list',(req,res)=>{
    console.log(req.aaa);
    res.send({name:'list',...req.aaa})
})

router.get('/news/:id',(req,res)=>{
    // req.params
    res.send({name:'news',...req.params})
})

router.get("/books",(req,res)=>{
    res.send({name:'books',...req.query})
})

router.post('/post',(req,res)=>{
    res.send({name:'post',...req.body})
})

module.exports = router